<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="script/jquery-1.11.3.js"></script>
<link rel="stylesheet" href="bootstrap-3.0.3/css/bootstrap.min.css">
<script type="text/javascript" src="bootstrap-3.0.3/js/bootstrap.js"></script>
<script type="text/javascript" src="script/jquery.validate.min.js"></script>
<script type="text/javascript" src="script/messages_zh.js"></script>
<script type="text/javascript">
	$(function() {
		var flag=false;
		$("#inputUserName").blur(function() {
			$.get("checkUserName", {
				userName : $(this).val()
			}, function(data) {
				//alert(data);
				var data = eval(data);
				if (data) {
					$(".error:first").html("用户名已重复，请重新制定");
					flag=false;
				} else {
					$(".error:first").html("");
					flag=true;
				}

			})
		})

		$.validator.setDefaults({
			submitHandler : function() {
				if(flag){
					$("#myform").submit();
				}
				
			}
		});

		$("#myform").validate();
	})
</script>
</head>
<body>
	<div class="container">
		<%@ include file="shared/front_header.jsp"%>
		<div class="row">
			<div class="col-md-9 col-md-push-3" style="left: 269px";>
				<form id="myform" class="form-horizontal" action="registerUser"
					method="post">
					<div class="control-group">
						<label class="control-label" for="inputUserName">UserName</label>
						<div class="controls">
							<input type="text" id="inputUserName" placeholder="UserName"
								name="userName" required /> <label class="error"></label>
						</div>
					</div>
					<div class="control-group">
						<label class="control-label" for="inputPassword">Password</label>
						<div class="controls">
							<input type="password" id="inputPassword" placeholder="Password"
								name="passWord" required minlength="3" /> <label class="error"></label>
						</div>
					</div>
					<div class="control-group">
						<label class="control-label" for="inputName">Name</label>
						<div class="controls">
							<input type="text" id="inputName" placeholder="name" name="name"
								required /> <label class="error"></label>
						</div>
					</div>
					<div class="control-group">
						<label class="control-label" for="inputPhone">Phone</label>
						<div class="controls">
							<input type="text" id="inputPhone" placeholder="phone"
								name="phone" required /> <label class="error"></label>
						</div>
					</div>
					<div class="control-group">
						<label class="control-label" for="inputEmail">Email</label>
						<div class="controls">
							<input type="email" id="inputEmail" placeholder="email"
								name="email" required /> <label class="error"></label>
						</div>
					</div>

					<div class="control-group">
						<div class="controls">
							<br />
							<button type="submit" class="btn">Register</button>
							<span>${error }</span>
						</div>
					</div>
				</form>

			</div>

			<%@ include file="shared/nav.jsp"%>

		</div>



	</div>
</body>
</html>